<template>
	<view>
		<uni-popup ref="popupRef" type="center" background-color="#fff" :is-mask-click="false">
			<view class="popup-content">
				<view class="popup-header">
					<text class="title">是否需要合托</text>
						<view class="bill-info">
							
						</view>
				</view>
		


				<view v-if class="process-selector">
					<picker 
						@change="onProcessChange" 
						:value="selectedIndex"
						:range="currentProcesses"
						range-key="value"
					>
						<view class="picker">
							{{ selectedIndex >= 0 ? currentProcesses[selectedIndex].value : '请选择打印方式' }}
							<uni-icons type="arrowdown" size="22" color="#999"></uni-icons>
						</view>
					</picker>
				</view>

				<view class="popup-footer">
					<button class="cancel-btn" @click="closePopup">取消</button>
					<button class="confirm-btn" :disabled="selectedIndex < 0" @click="confirmSelection">确定</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		
	} from '@/utils/api.js';
	export default {
		data() {
			return {
			
				visible: false,
				loading: false,
				currentItem: {},
				currentMoBillNo: '', // 存储生产订单编号
				currentProcesses: [
				{
					'operNo':'A',
					'value':'是'
				},
				{
					'operNo':'B',
					'value':'否',
				}
				],
				selectedIndex: -1, // 当前选中的工序索引
				selectedProcess: null // 当前选中的工序对象
			}
		},
		methods: {
			open(item) {
		
				this.visible = true;
				this.$refs.popupRef.open('center');
				this.loading = true;
			},
			closePopup() {
				this.visible = false;
				this.$refs.popupRef.close();
			},
			// 处理工序选择变化
			onProcessChange(e) {
				this.selectedIndex = e.detail.value;
				this.selectedProcess = this.currentProcesses[this.selectedIndex];
			},
			// 确认选择
			confirmSelection() {
				if (this.selectedIndex >= 0 && this.selectedProcess) {
				
					this.$emit('success', this.selectedProcess.value)
					this.closePopup();
					
						
				
				}
			},
			
		}
	}  
</script>

<style lang="scss" scoped>
	/* 新增弹窗样式 */
	.popup-content {
		width: 80vw;
		padding: 20rpx;
		border-radius: 20rpx;
		background-color: #fff;
	}

	.popup-header {
		text-align: center;
		padding: 20rpx 0;
		border-bottom: 1px solid #eee;
	}

	.title {
		font-size: 18px;
		color: #000000;
		font-weight: bold;
	}
	/* 新增单据信息样式 */
	.bill-info {
		display: flex;
		flex-direction: column;
		align-items: center;
		font-size: 20px;
		color: #000000;
		line-height: 1.6;
		margin-top: 10rpx;
	}
	
	/* 新增下拉菜单样式 */
	.process-selector {
		margin: 30rpx 30rpx;
		border: 1px solid #e5e5e5;
		border-radius: 12rpx;
		padding: 20rpx 30rpx;
		background-color: #f9f9f9;
	}
	.picker {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 20px;
		color: #000000;
	}

	.popup-footer {
		padding: 20rpx 0;
		display: flex;
		justify-content: space-between;
		margin-top: 20rpx;
	}
	
	.confirm-btn, .cancel-btn {
		width: 240rpx;
		height: 100rpx;
		border-radius: 10rpx;
		font-size: 22px;
	}
	
	.confirm-btn {
		background-color: #4CAF50;
		color: white;
	}
	
	.confirm-btn[disabled] {
		background-color: #cccccc;
		color: #666;
		opacity: 0.7;
	}
	
	.cancel-btn {
		background-color: #e25447;
		color: #fff;
	}

</style>